/*
 * Copyright 2022 The Open Islands Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.openislands.oi.pojo.dto;

import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import org.openislands.oi.constant.NodeState;
import org.openislands.oi.dao.entity.NodeDO;

import java.io.Serializable;

public class NodePageDTO implements Serializable {
    private String nodeId;
    private String nodeName;
    private String owner;
    private NodeState state;
    private Boolean orderRule;
    private String orderField;
    private Integer pageNum;
    private Integer pageSize;

    public String getNodeId() {
        return nodeId;
    }

    public void setNodeId(String nodeId) {
        this.nodeId = nodeId;
    }

    public String getNodeName() {
        return nodeName;
    }

    public void setNodeName(String nodeName) {
        this.nodeName = nodeName;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public NodeState getState() {
        return state;
    }

    public void setState(NodeState state) {
        this.state = state;
    }

    public Boolean getOrderRule() {
        return orderRule;
    }

    public void setOrderRule(Boolean orderRule) {
        this.orderRule = orderRule;
    }

    public String getOrderField() {
        return orderField;
    }

    public void setOrderField(String orderField) {
        this.orderField = orderField;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public SFunction<NodeDO, Object> getOrderFields() {
        if ("updateTime".equals(this.orderField)) {
            return NodeDO::getUpdateTime;
        }
        return NodeDO::getCreateTime;
    }
}
